import { translate, plainMatrix } from '../../math/index.js'
import { gridCellPoints } from '../../algorithm/grid.js'
import { colorCircle } from '../../color/index.js'
import { deepClone } from '../../utils/index.js'
import { pattern } from "./pattern.js"

let r = 25
let gps = gridCellPoints()
gps = plainMatrix(gps)
let len = gps.length
let colors = colorCircle(len, 0.5)
let colorsLen = colors.length
let arr = gps.map((t, i) => {
    let o = t
    let points = [translate(t, [r, r]), translate(t, [-r, -r])]
    return {
        shape: 'circle',
        r,
        o,
        points,
        props: {
            fill: colors[i % colorsLen]
        }
    }
})
export const shapes = deepClone(arr)
export const circles = deepClone(arr)
export const rects = deepClone(arr).map(t => {
    return {
        ...t,
        shape: 'rect'
    }
})

export const lines = deepClone(arr).map(t => {
    return {
        ...t,
        shape: 'line',
        props: {
            stroke: t.props.fill,
            strokeWidth: 2
        }
    }
})

export const curves = deepClone(arr).map(t => {
    return {
        ...t,
        shape: 'curve',
        props: {
            stroke: t.props.fill,
            strokeWidth: 2
        }
    }
})

export const sawtooths = deepClone(arr).map(t => {
    return {
        ...t,
        shape: 'sawtooth',
        props: {
            // stroke: t.props.fill,
            // strokeWidth: 2
        }
    }
})


let pt = pattern[0]
export const circlesPattern = deepClone(circles).map(t => {

    return {
        ...t,
        pattern: pt.id
    }
})

export const rectsPattern = deepClone(rects).map(t => {

    return {
        ...t,
        pattern: pt.id
    }
})
